<template>
	<view class="record">
		<view class="teamList_box">
			<view class="teamListTitle">
				<tui-dropdown-list :show="dateVis" :top="76" :height="400">
					<template v-slot:selectionbox>
						<view @click="openDate">{{recordDate}}</view>
					</template>
					<template v-slot:dropdownbox>
						<tui-list-view style="box-shadow: 0 0 20rpx rgba(0,0,0,.3);">
							<tui-list-cell @click="selDate(item)" v-for="(item,index) in dateArr" :key="index">
								<view>{{item}}</view>
							</tui-list-cell>
						</tui-list-view>
					</template>
				</tui-dropdown-list>
				<!-- <view class="more">获得:{{infoIntegral.in}}&nbsp;&nbsp;&nbsp;&nbsp;使用:{{infoIntegral.out}}</view> -->
			</view>
			<view v-if="recordList.length > 0">
				<tui-list-view backgroundColor="#fff">
					<tui-list-cell v-for="(item,index) in recordList" :key="index">
						<view class="teamList">
							<view class="label">
								<view class="text">
									<view class="h1">{{item.comment}}</view>
									<view class="h2">{{item.useTime}}</view>
								</view>
							</view>
							<view class="val">
								<view class="text" v-if="item.isDeduct == 0" style="color: #F5A649;">
									+{{item.amount}}
								</view>
								<view class="text" v-if="item.isDeduct == 1" style="color: #111;">
									-{{item.amount}}
								</view>
							</view>
						</view>
					</tui-list-cell>
				</tui-list-view>
			</view>
			<view v-else-if="recordList.length == 0">
				<tui-no-data style="margin-top: 0rpx;" :imgUrl="imgConfig + 'images/mall/my_course_empty.png'">暂无数据</tui-no-data>
			</view>
		</view>
		<!--加载loadding-->
		<tui-loadmore v-if="loadding" :index="3" type="red"></tui-loadmore>
		<tui-nomore v-if="!pullUpOn" backgroundColor="#f7f7f7"></tui-nomore>
		<!--加载loadding-->
	</view>
</template>

<script>
	const util = require("@/utils/util.js")
	const app = getApp()
	export default {
		name: '',
		components: {

		},
		props: {

		},
		data() {
			return {
				imgConfig: util.domainImg,
				recordList: [], // 积分列表
				infoIntegral: {}, // 积分信息

				recordDate: "选择日期",
				userDate: "",
				dateVis: false,
				dateArr: [],

				current: 1,
				pages: '',
				loadding: false,
				pullUpOn: true,
			};
		},
		computed: {

		},
		watch: {

		},
		onLoad() {
			this.getDate();
			this.getList();
		},
		onShow() {

		},
		// 下拉刷新
		onPullDownRefresh: function() {
			this.current = 1;
			this.pullUpOn = true;
			this.loadding = false;
			this.recordDate = "选择日期";
			this.userDate = "";
			this.getList();
			uni.stopPullDownRefresh();
		},
		// 上拉加载
		onReachBottom: function() {
			this.loadding = true;
			if (this.current == this.pages) {
				this.loadding = false;
				this.pullUpOn = false;
			} else {
				this.getList(true);
				this.loadding = false;
			}
		},
		methods: {
			openDate() {
				this.dateVis = !this.dateVis;
			},
			// 选择日期
			selDate(date) {
				this.dateVis = false;
				this.recordDate = date;
				this.userDate = date;
				this.getList();
			},
			// 获取月份
			getDate() {
				util.request('my/amountRecordMonth').then(res => {
					if (res.code == 0) {
						this.dateArr = res.data
					}
				});
			},
			// 积分记录列表
			getList(selet_type) {
				let that = this;
				let loadData;
				that.pullUpOn = true;
				if (selet_type) {
					loadData = JSON.parse(JSON.stringify(that.recordList));
					that.current = that.current + 1;
				}
				util.request('my/amountPage', {
					current: that.current,
					size: 15,
					userDate: this.userDate
				}, 'POST').then(res => {
					if (res.code == 0) {
						that.recordList = res.data.records
						that.pages = res.data.pages
						if (selet_type) {
							that.recordList = loadData.concat(res.data.records);
						}
					}
				});
			}
		},
	};
</script>

<style lang="scss">
	.record {
		.head {
			width: 100%;
			position: relative;

			.taskBg {
				width: 100%;
				position: absolute;
				left: 0;
				top: 0;
			}

			.text {
				width: 100%;
				position: relative;
				z-index: 1;
				padding: 90rpx 0;
				text-align: center;
				font-size: 28rpx;
				color: #fff;

				.num {
					font-size: 56rpx;
					font-weight: bold;
				}

				image {
					width: 100rpx;
					height: 100rpx;
				}
			}
		}

		.menu {
			width: 100%;
			display: flex;
			position: relative;
			z-index: 1;
			background: #fff;

			.nav {
				flex: 1;
				display: flex;
				align-items: center;
				justify-content: center;
				height: 140rpx;
				text-align: center;

				.label {
					font-size: 28rpx;
					color: #999;
				}

				.val {
					font-size: 32rpx;
					font-weight: bold;
					color: #1ABC9C;
				}
			}
		}
		.teamList_box {
			padding: 20rpx 30rpx 0;
			
			.teamListTitle {
				// background: none;
			
				/deep/.tui-dropdown-view {
					overflow: initial;
				}
			}
			
			.teamList {
			
				.btn {
					padding: 10rpx 30rpx;
				}
			
				.btnA {
					background: gray;
				}
			}
		}
	}
</style>
